package my.jwds.p2028;

public class MissingRolls {

    public static void main(String[] args) {

        MissingRolls obj = new MissingRolls();
        long start = System.currentTimeMillis();
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }

    public int[] missingRolls(int[] rolls, int mean, int n) {
        int msum = 0;
        for (int roll : rolls) {
            msum += roll;
        }
        int sum = mean*(rolls.length+n);
        int nsum = sum-msum;
        if (nsum < n || nsum > n*6)return new int[0];
        int nRolls[] = new int[n];
        for (int i = n-1; i >=0; i--) {
            nRolls[i] = nsum / (i+1);
            nsum -= nRolls[i];
        }
        return nRolls;
    }

}